import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import get from '@dfeidao/atom-web/local/get';
export default async function a003(fd: IFeidaoAiBrowserComponent) {

	const cust_name = fd.data.node.querySelector<HTMLInputElement>('[data-name="cust_name"]').value;
	if (!cust_name) {
		alert('请输入客户名称');
		return;
	}
	const contact_address = fd.data.node.querySelector<HTMLInputElement>('[data-name="contact_address"]').value;
	if (!contact_address) {
		alert('请输入联系地址');
		return;
	}
	const industry_domain_name = fd.data.node.querySelector<HTMLInputElement>('[data-name="industry_domain_name"]').value;
	if (!industry_domain_name) {
		alert('请输入行业领域名称');
		return;
	}
	const memo = fd.data.node.querySelector<HTMLInputElement>('[data-name="memo"]').value;

	const data = get(fd, 'industry_domain') as { industry_domain_no: string };
	const res = await nodejs<{ code: number; result: string }>('customer-care/zj-000002/s001', {
		filter: {
			cust_name,
			contact_address,
			memo,
			industry_domain_no: data.industry_domain_no,
			industry_domain_name
		}
	});
	if (res.code === 1) {
		alert('保存成功');
		window.location.reload();
	} else {
		alert('保存失败');
	}
}
